<template>
  <div>
    <h3>预览</h3>
    <el-form-item label="商品名称" prop="name">
      <span>{{ form.name }}</span>
    </el-form-item>
    <el-form-item label="副标题" prop="subTitle">
      <span>{{ form.subTitle }}</span>
    </el-form-item>
    <el-form-item label="商品价格" prop="price">
      <span>{{ form.price }}</span>
    </el-form-item>
    <el-form-item label="商品数量" prop="stock">
      <span>{{ form.stock }}</span>
    </el-form-item>
    <el-form-item label="是否上架">
      <span>{{ form.status ? '是' : '否' }}</span>
    </el-form-item>
    <el-form-item label="是否热门">
      <span>{{ form.hotFlag ? '是' : '否' }}</span>
    </el-form-item>
    <el-form-item label="分类名称" class="category">
      <span>{{ form.categoryId }}</span>
      <span>{{ form.subCategoryId }}</span>
    </el-form-item>
    <el-form-item label="商品参数">
      <div class="paramList" v-for="(item, index) in form.param" :key="index">
        <span>{{ item.attr_name }}</span>
        <div>
          <el-tag class="ml-2" v-for="(item, index) in item.attr_vals" :key="index" type="info" style="width: 6rem; 
     overflow: hidden;
     text-overflow: ellipsis;
     white-space: nowrap;">{{ item }}</el-tag>
        </div>
      </div>
    </el-form-item>

    <el-form-item label="商品详情">
      <div v-html="form.detail"></div>
    </el-form-item>

  </div>
</template>

<script setup>
import { defineProps } from 'vue'
const props = defineProps(['form'])


</script>

<style lang="scss" scoped>
.category {
  span {
    display: inline-block;
    margin-right: 10px;
  }
}

.paramList {
  margin-bottom: 10px;
  border: 1px solid #ccc;
  padding: 10px;

  span {
    display: inline-block;
    margin-right: 10px;
    font-weight: bold;
    font-size: 14px;
    color: #666;
    width: 100px;
    text-align: center;
    vertical-align: top;
    margin-top: 5px;
    margin-bottom: 5px;

    &:last-child {
      margin-right: 0;
    }
  }
}
</style>